import java.util.HashSet;
import java.util.PriorityQueue;
import java.util.Set;

public class project {
    public int nthSuperUglyNumber(int n, int[] primes) {
        PriorityQueue<Long> queue=new PriorityQueue<>();
        queue.offer(1l);
        long tmp=-1;
        for(int i=0;i<n;i++){
            long res=queue.poll();
            while(res==tmp){
                res=queue.poll();
            }
            if(i==n-1){
                return (int)res;
            }
            for(int j : primes){
                queue.offer(j*tmp);
            }
            tmp=res;
        }
        return -1;
    }









    public int maximumScore(int a, int b, int c) {
        if(a+b<=c){
            return a+b;
        }else if(a+c<=b){
            return a+c;
        }else if(b+c<=a){
            return b+c;
        }
        return (a+b+c)/2;
    }
}
